package com.grad.webstudy.controller;

import com.github.pagehelper.PageInfo;
import com.grad.webstudy.annota.LoginAuthorization;
import com.grad.webstudy.service.CollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:
 * @Author: zjf
 * @Date: 2020/2/4 17:00.
 */
@RestController
@RequestMapping("/collect")
public class CollectController {

    @Autowired
    private CollectService collectService;


    @PostMapping("/add")
    @LoginAuthorization
    public boolean addCollect(int courseId){
        return collectService.addCollect(courseId);
    }

    @GetMapping("/queryAllByPage")
    @LoginAuthorization
    public PageInfo queryAllByPage(@RequestParam(defaultValue = "1") int currPage,@RequestParam(defaultValue = "5") int pageSize){
        return collectService.queryCollectByPage(currPage, pageSize);
    }

    @DeleteMapping("/delete")
    @LoginAuthorization
    public boolean deleteCollects(String ids){
        return collectService.deleteCollects(ids);
    }
}
